Skip to main content

Diagnostique

Remonté de l'anomalie dans le canal Teams :

Une erreur est survenue lors de la mise à jour des "LienProjetTitulaire" Détails SQL : Erreur SQL -2: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (Ligne: 0, Procédure: ) Erreur SQL 0: Operation cancelled by user. (Ligne: 0, Procédure: ) Erreur SQL 3621: The statement has been terminated. (Ligne: 1, Procédure: ) at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at Microsoft.Data.SqlClient.SqlBulkCopy.RunParser(BulkCopySimpleResultSet bulkCopyHandler) at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinuedOnSuccess(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinued(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.CopyBatchesAsync(BulkCopySimpleResultSet internalResults, String updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source) at Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet internalResults, CancellationToken cts, TaskCompletionSource`1 source) --- End of stack trace from previous location --- at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context Type type IEnumerable 1 entities TableInfo tableInfo Action 1 progress Boolean isAsync CancellationToken cancellationToken.md) at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context Type type IEnumerable 1 entities TableInfo tableInfo Action 1 progress Boolean isAsync CancellationToken cancellationToken.md) at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context Type type IEnumerable 1 entities TableInfo tableInfo Action 1 progress Boolean isAsync CancellationToken cancellationToken.md) at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.InsertAsync[T](DbContext context Type type IEnumerable 1 entities TableInfo tableInfo Action 1 progress CancellationToken cancellationToken.md) at EFCore.BulkExtensions.SqlBulkOperation.InsertAsync[T](DbContext context Type type IEnumerable 1 entities TableInfo tableInfo Action 1 progress CancellationToken cancellationToken.md) at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context Type type IEnumerable 1 entities OperationType operationType BulkConfig bulkConfig Action 1 progress CancellationToken cancellationToken.md) at NC.CAM.Data.Portal.Api.Infrastructure.Services.EntityLoaderService.BackupAndUpdateTableAsync(Boolean isDeltaUpdate, IEnumerable`1 ftpFileInfos, KeyValuePair`2 entityTypeByTableName) in D:\a\1\s\src\NC.CAM.Data.Portal.Api\Infrastructure\Services\EntityLoaderService.cs:line 195 | MESSAGE : Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Operation cancelled by user. The statement has been terminated. | INNER MESSAGE : The wait operation timed out.

Le BulkCopy dispose sa propre limitation (timeout) interne. Augmenter le timeout pour les requêtes vers la bdd context.Database.SetCommandTimeout(300); n'est pas suffisant.

Résolution

  1. Correction du code

Ajout d'une configuration pour augmenter le timeout de Bulkcopy : var bulkConfig = new BulkConfig { BulkCopyTimeout = 300 };